package utilities;

import java.sql.Connection;
import java.sql.SQLException;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.*;


public class ConnectionManagement {

	private DataSource datasource;
	private Context context;
	
	public ConnectionManagement() {
		try{
			context = new InitialContext();
			datasource = (DataSource) context.lookup("java:comp/env/postgresConnection");
		}catch(NamingException e){
			System.out.println("ConnectionManagement"+e);
		}
	}
	
	public Connection getConnection(){
		try{
			return datasource.getConnection();
		}catch(SQLException e){
			System.out.println("getConnection"+e);
		}
		return null;
	}

}

